import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:nft_shop/res/global.dart';

/// 封装输入框
class TextFieldItem extends StatelessWidget {

  const TextFieldItem({
    Key? key,
    this.controller,
    required this.title,
    this.keyboardType = TextInputType.text,
    this.hintText = '',
    this.focusNode,
    this.contentTextStyle,
  }): super(key: key);

  final TextEditingController? controller;
  final String title;
  final String hintText;
  final TextInputType keyboardType;
  final FocusNode? focusNode;
  final TextStyle? contentTextStyle;

  @override
  Widget build(BuildContext context) {
    final Row child = Row(
      children: <Widget>[
        Text(title,style: TextStyle(color: Global.kTheme.textPrimary6,fontSize: 14,fontFamily: Global.myRegularFont),),
        SizedBox(width: 16),
        Expanded(
          child: Semantics(
            label: hintText.isEmpty ? '请输入$title' : hintText,
            child: TextField(
              focusNode: focusNode,
              keyboardType: keyboardType,
              controller: controller,
              textAlign: TextAlign.right,
              style: contentTextStyle??null,
              decoration: InputDecoration(
                hintText: hintText,
                hintStyle: TextStyle(color: Global.kTheme.inputHint1),
                border: InputBorder.none, //去掉下划线
                //hintStyle: TextStyles.textGrayC14
              ),
            ),
          ),
        ),
        SizedBox(width: 16),
      ],
    );
    
    return Container(
      height: 60.0,
      margin: const EdgeInsets.only(left: 15.0),
      width: double.infinity,
      decoration: BoxDecoration(
        border: Border(
          bottom: Divider.createBorderSide(context, width: 0.6),
        ),
      ),
      child: child,
    );
  }

}
